<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;padding: 0;
        }
        .loginbox{
            margin: 100px 30px;
        }
        .loginbox input{
            height: 40px;
            margin-bottom: 20px;
            width: 100%;
            border: 1px solid #ccc;
        }
        
    </style>
</head>
<body>
    <div class="loginbox">
        <input type="text" placeholder="用户">
        <input type="text" placeholder="密码">
        <input type="button" value="登陆" class="loginbtn">
    </div>
    <script src="./axios.min.js"> </script>
    <script>
        var inputs = document.querySelectorAll("input");

        inputs[2].onclick = function(){
            axios.get("/api/login",{params:{ user: inputs[0].value,pass:inputs[1].value  }}).then((res)=>{
                if( res.data.code == 200){ //登陆成功
                    console.log(res.data.msg);
                    location.href = "./index.html";//跳转到其他页面
                }
                else{
                    console.log(res.data.msg);
                }
            })
        }
    </script>
</body>
</html>
